﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using K.Contract;
using System.Threading;
namespace K.Service
{
    public class TestServerService : IServerThread
    {

        private static int _i;
        private bool _exists;
        public void DoThread()
        {
            _exists = false;
            _i = 1;
            Thread testThread = new Thread(new ThreadStart(DoThreadFun));
            testThread.Start();
        }

        private void DoThreadFun()
        {
            DateTime dt = DateTime.Now;
            TimeSpan timeSpan = new TimeSpan(0, 0, 1);
            for (; ; )
            {
                if (DateTime.Now - dt > timeSpan)
                {
                    _i++;
                    dt = DateTime.Now;
                }
                if (_exists)
                    break;
            }


        }
        public int GetI()
        {
            return _i;
        }

        public void SetExsits()
        {
            _exists = true;
        }

    }

    
}
